def format_file_size(size):
    size = int(size)
    # 单位列表
    units = ['B', 'KB', 'MB', 'GB']

    unit_index = 0
    while size >= 1024 and unit_index < len(units) - 1:
        size /= 1024
        unit_index += 1

    formatted_size = f"{round(size)} {units[unit_index]}"
    return formatted_size
